package com.carleasoft.mps.cms.business.train.controller;

import com.carleasoft.mps.cms.business.train.bean.entity.TrainScore;
import com.carleasoft.mps.cms.business.train.bean.po.ContentListPo;
import com.carleasoft.mps.cms.business.train.bean.po.GetTrainExamPo;
import com.carleasoft.mps.cms.business.train.bean.po.StatisticsByYearPo;
import com.carleasoft.mps.cms.business.train.bean.po.StatisticsConsumePo;
import com.carleasoft.mps.cms.business.train.bean.vo.ContentInfoVo;
import com.carleasoft.mps.cms.business.train.bean.vo.StatisticsGradesVo;
import com.carleasoft.mps.cms.business.train.bean.vo.TrainArchiveVo;
import com.carleasoft.mps.cms.business.train.service.TrainExamService;
import com.carleasoft.mps.cms.business.train.service.TrainPlanService;
import com.carleasoft.mps.core.result.R;
import com.carleasoft.mps.core.utils.IBeanUtil;
import com.carleasoft.mps.data.mybatisplus.page.PageBase;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Description: 前端训练档案库
 * @Author: fan
 */
@RestController
@RequestMapping("/trainArchive")
public class TrainArchiveController {
    @Autowired
    private TrainPlanService trainPlanService;
    @Autowired
    private TrainExamService trainExamService;

    /**
     * 训练计划-查询各种计划（查七条）
     */
    @PostMapping("/queryPlan")
    public R<TrainArchiveVo> queryPlan() {
        return R.ok(trainPlanService.queryPlan());
    }

    /**
     * 训练考核情况
     */
    @PostMapping("/trainCheck")
    public R trainCheck(@RequestBody GetTrainExamPo getTrainExamPo) {
        return R.ok(trainExamService.getTrainExam(getTrainExamPo));
    }

    /**
     * 根据考核编码统计考核
     */
    @PostMapping("/statisticsExam")
    public R statisticsExam(@RequestBody TrainScore trainScore) {
        return R.ok(trainExamService.statisticsExam(trainScore));
    }

    /**
     * 根据考核编码成绩统计
     */
    @PostMapping("/statisticsGrades")
    public R statisticsGrades(@RequestBody TrainScore trainScore) {
        return R.ok(trainExamService.statisticsGrades(trainScore));
    }

    /**
     * 药品消耗情况统计
     */
    @PostMapping("/statisticsConsume")
    public R statisticsConsume(@RequestBody StatisticsConsumePo statisticsConsumePo) {
        return R.ok(trainExamService.statisticsConsume(statisticsConsumePo));
    }

    /**
     * 油料消耗情况统计
     */
    @PostMapping("/statisticsConsumeOfOil")
    public R<List<StatisticsGradesVo>> statisticsConsumeOfOil(@RequestBody StatisticsConsumePo statisticsConsumePo) {
        return R.ok(trainExamService.statisticsConsumeOfOil(statisticsConsumePo));
    }

    /**
     * 用车情况统计
     */
    @PostMapping("/statisticsByCar")
    public R statisticsByCar() {
        return R.ok(trainExamService.statisticsByCar());
    }

    /**
     * 全年概况统计
     */
    @PostMapping("/statisticsByYear")
    public R statisticsByYear(@RequestBody StatisticsByYearPo statisticsByYearPo) {
        return R.ok(trainExamService.statisticsByYear(statisticsByYearPo));
    }

    /**
     * 不同类型查询考核数据
     *
     * @return
     */
    @PostMapping("/contentList")
    public R contentList(@RequestBody ContentListPo contentListPo) {
        IBeanUtil.paramVerify(contentListPo,"type","year");
        List<ContentInfoVo> contentInfoVos = trainExamService.contentList(contentListPo);
        return R.ok(contentInfoVos);
    }
}
